import { createRouter, createWebHashHistory } from 'vue-router'
import login from '@/views/login'
import layout from '@/views/layout'
import home from '@/views/home'
import category from '@/views/category'
import good from '@/views/good'
import cart from '@/views/cart'
import settlement from '@/views/settlement'
import pay from '@/views/pay'
import back from '@/views/pay/back.vue'

const routes = [
  {
    path: '/login',
    component: login
  },
  {
    path: '/',
    component: layout,
    children: [{
      path: 'category/:id',
      component: category
    },
    {
      path: '',
      component: home
    },
    {
      path: 'good/:id',
      component: good
    },
    {
      path: 'cart',
      component: cart
    },
    {
      path: 'settle',
      component: settlement
    },
    {
      path: 'pay',
      component: pay
    },
    {
      path: 'pay/callback',
      component: back
    }
    ]
  }
]

const router = createRouter({
  // 使用 hash 方式实现路由
  history: createWebHashHistory(),
  // 配置路由规则,写法和以前一样
  routes
})

export default router
